﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace IRC.IRepairClouds.DataLayer.Expressions
{
    public class ParametersReplacer : ExpressionVisitor
    {
        private Expression _expression;
        private Expression _newParam;
        public ParametersReplacer(Expression expression, Expression newParam)
        {
            expression.ThrowIfNull();
            newParam.ThrowIfNull();

            _expression = expression;
            _newParam = newParam;
        }

        public Expression Process()
        {
            return base.Visit(_expression);
        }

        protected override Expression VisitParameter(ParameterExpression p)
        {
            return _newParam;
        }
    }
}
